fix: nested trait @use, use original class file name to get trait data
#4813
+89
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
Git bisect shows that commit d8ec11f introduced a regression in nested trait
@useresolution, e.g., the following no longer passes the template to the base trait:This bug only seems to show up when the classes are in different files and namespaces, so it was impossible to replicate on the playground (see https://phpstan.org/r/985be0cb-f0ba-47e9-8f3c-3f7f63dccdfa). In the e2e test, I also tried to just have a
data/directory withframework.phpand asrc.phpfiles that had the respective namespace and classes in them but that passed and did not replicate the failure. So sorry for the 6 individual classes / files but this was the only way that I could replicate.Note
I'm not sure if this is the best fix, this was just suggested by the AI agent that was helping me diagnose the cause of this regression. This does however, fix the issue I was having...
Warning
There seems to be some additional caching going on that's not being cleared by
phpstan clear-result-cache. Running the following command before and after the commit that fixes the issue does not result in a different output unless thetmp/directory is completely cleared in between runs (i.e., if ran before the fix and then ran after the fix the command still results in an error when it should be passing; and the same backwards, running after the fix and then before the fix results in a passing command which should be failing):Thanks!